define([
  'jquery',
  'backbone',
  'vue',
  'text!tmpl/ext/alert.html'
], function($, Backbone, Vue, layoutTemplate) {
  var vueViews = {};
  var AppView = Backbone.View.extend({
    // el: 'body',
    initialize: function() {
      this.on('showAlert', function(msg) {
        vueViews['alertModule'].toggleAlert(msg);
      });
    },
    render: function() {
      var that = this;
      $('body').append(layoutTemplate);////////////////////////如果一个页面中需要出现多次模块需要修改这里
      vueViews['alertModule'] = renderAgentView();
    }
  });
  return AppView;

  function renderAgentView() {
    return new Vue({
      el: '.m-alert',//////////////和这里
      ready: function() {
        var self = this;
      },
      data: {
        showAlertFlag: false,
        errMsg: ''
      },
      methods: {
        toggleAlert: function(msg) {
          if (this.showAlertFlag)
            this.showAlertFlag = false;
          else
            this.showAlertFlag = true;
          (msg ? this.errMsg = msg : '');
        }
      }
    });
  }
})
